//package com.spring.boot.springBoot.manyDataSource;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
//import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
//import org.springframework.orm.jpa.JpaTransactionManager;
//import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
//import org.springframework.transaction.PlatformTransactionManager;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//import javax.persistence.EntityManager;
//import javax.sql.DataSource;
//import java.util.Map;
//
///**
// * Created by pactera on 2018/1/12.
// */
//@Configuration
//@EnableTransactionManagement
//@EnableJpaRepositories(entityManagerFactoryRef = "pacteraEntityManagerFactoryBean",transactionManagerRef = "pacteraTransactionManager",
//basePackages = "com.spring.boot.springBoot.repository.secondResponsity")
//public class SecondDataSourceConfig {
//
//
//    @Autowired
//    private DataSource pacteraDataSource;
//    @Autowired
//    private JpaProperties jpaProperties;
//
//    @Bean(name="pacteraEntityManager")
//    public EntityManager entityManager(EntityManagerFactoryBuilder entityManagerFactoryBuilder){
//        return entityManagerFactoryBean(entityManagerFactoryBuilder).getObject().createEntityManager();
//    }
//
//
//    @Bean(name="pacteraEntityManagerFactoryBean")
//    public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(EntityManagerFactoryBuilder builder){
//        return builder.dataSource(pacteraDataSource)
//                .properties(getVendorProperties(pacteraDataSource))
//                .packages("com.spring.boot.springBoot.entity") // 设置实体类所在位置
//                .persistenceUnit("spitPersistenceUnit")
//                .build();
//    }
//
//    public Map<String,String> getVendorProperties(DataSource dataSource){
//        return jpaProperties.getHibernateProperties(dataSource);
//    }
//
//
//    @Bean(name = "pacteraTransactionManager")
//    public PlatformTransactionManager platformTransactionManager(EntityManagerFactoryBuilder builder) {
//        return new JpaTransactionManager(entityManagerFactoryBean(builder).getObject());
//    }
//
//}
